#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "rngs.h"
#include "testhelpers.c"

// This function tests village

void setHand(struct gameState *state){
    state->hand[0][0] = village;
    state->handCount[0] = 1;
}

int main(){
    struct gameState *state = malloc(sizeof(struct gameState));
    setState(state);
    resetDeck(state);
    setHand(state);

    printf("Starting Village Card Effect Test\n");

    resetFlag();

    cardEffect(village, 0, 0, 0, state, 0, 0);

    state->numActions--;// mimics the functionality elsewhere in code that decrements numActions

    // village should provide +2 actions +1 card, and discards the card
    if(state->handCount[0] != 1)
        assertMessage("Handcount should be %d but it is %d\n", 1, state->handCount[0]);
    if(state->playedCardCount != 1)
        assertMessage("Played Card Count should be %d but it is %d\n", 1, state->playedCardCount);
    if(state->playedCards[0] != village)
        assertMessage("The last played should be %d but it is %d\n", village, state->playedCards[0]);
    if(state->numActions != 2)
        assertMessage("Number of actions should be %d but it is %d\n", 2, state->numActions);

    if(testState() == 0)
        printf("Village Card Effects passed\n");
    else
        printf("Village Card Effects failed\n");

    free(state);
    return 0;
}
